//
//  KLineViewController.swift
//  JunYiProject
//
//  Created by xiaogxjkz on 2021/6/9.
//

import UIKit
import YYKit

class KLineViewController: BaseViewController {
    
    //MARK: - override
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // Do any additional setup after loading the view.
    }
    
    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        
        MarketSetting.arrMinorKPI = ["成交量","MACD","KDJ"]
        
        //默认横屏
        Utils.shareInstance().screenDirection()
    }
    
    override func viewWillDisappear(_ animated: Bool) {
        super.viewWillDisappear(animated)
        
        MarketSetting.arrMinorKPI = ["MACD","KDJ"]
        PlaySound.manager.unInit()
    }
    
    /// 设置导航
    override func layoutNavigation() {
        
    }
    
    /// 添加视图
    override func addSubViews() {
        self.view.addSubview(self.bgImage)
        self.view.addSubview(self.mainView)
        
        //播放背景声音
        PlaySound.manager.playMusic(strMName: "game_bg_sound")
    }
    
    /// 绑定事件
    override func bindViewModel() {
        
    }
    
    /// 设置约束
    override func updateViewConstraints() {
        
        self.bgImage.snp.makeConstraints {[weak self] make in
            guard let self = self else { return }
            make.edges.equalTo(self.view)
        }
        
        self.mainView.snp.makeConstraints {[weak self] make in
            guard let self = self else { return }
            make.edges.equalTo(self.view)
        }
        
        super.updateViewConstraints()
    }
    
    
    //MARK: - lazy load
    private lazy var viewModel:GameViewModel = {
        return GameViewModel.init()
    }()
    
    private lazy var mainView:KLineMainView = {
        return KLineMainView.init(ViewModel: self.viewModel)
    }()
    
    private lazy var bgImage:UIImageView = {
        autoreleasepool {
            let _imgv = UIImageView.init(image: YYImage.init(named: "game_background.png"))
            return _imgv
        }
    }()
    
}


//MARK: - 设备方向处理
extension KLineViewController {
    
    override var shouldAutorotate: Bool {
        get {
            return true
        }
    }
    
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        get {
            return .landscapeRight
        }
    }
}


//MARK: - 状态栏
extension KLineViewController {
    override var prefersStatusBarHidden: Bool {
        return true
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return self.statusBarStyle
    }
}
